<template>
  <div class="content-wrapper">
    <div class="content-types">
      <el-menu mode="horizontal" :default-active="`${navList[0].id}`" @select="navSelected">
        <el-menu-item index="-1" :disabled="true" class="new-content" :style="{color: `${typeInfo.color}`}">
          {{ typeInfo.title }}
        </el-menu-item>
        <el-menu-item :index="`${item.id}`" v-for="item in navList" :key="item.id">{{ item.title }}</el-menu-item>
        <!--        <el-menu-item index="2">前端开发</el-menu-item>-->
        <!--        <el-menu-item index="3">后端开发</el-menu-item>-->
        <!--        <el-menu-item index="4">精品免费</el-menu-item>-->
      </el-menu>
    </div>
    <div class="content-list">
      <a href="" class="content-item" v-for="i in 15" :key="i">
        <div class="content-item-card">
          <el-image class="content-item-img"
                    src="http://alioss.xueden.cn/2021/03/19/career/b7eb0386-7587-4ae7-8b98-1dc52fce1bc921.jpg"
                    fit="contain"/>
          <p class="content-item-title">Vue3开发企业级音乐Web App 明星讲师带你学习大厂高质量代码</p>
          <p class="participation-num">高级 · 1318人报名 </p>
          <div class="content-bottom"><span class="price">￥368.00</span></div>
        </div>
      </a>
    </div>
  </div>
</template>

<script setup>
import { defineProps, reactive } from 'vue'

const props = defineProps({
  typeInfo: {
    type: Object,
    default () {
      return {
        id: -1,
        title: '新品推荐',
        color: '#ec1500'
      }
    }
  },
  navList: {
    type: Array,
    required: true
  }
})


const navSelected = (index) => {
  console.log(`类型id: ${props.typeInfo.id},分类id: ${index}`)
}
</script>

<style lang="scss" scoped>

@media(max-width: 1152px) {
  .content-wrapper {
    display: none;
  }
}

.content-wrapper {
  box-shadow: 0 2px 4px 0 rgb(7 17 27 / 6%);
  width: 1152px;
  margin-left: auto;
  margin-right: auto;

  .content-types {
    .nav-to {
      text-decoration: none;
    }


    .el-menu {
      .el-menu-item {
        color: #1c1f21;
        padding: 0 22px;
        height: 100%;
        line-height: 80px;
      }

      .new-content.el-menu-item {
        font-size: 22px;
        font-weight: bold;
      }

      .new-content.el-menu-item.is-disabled {
        font-weight: 900;
        opacity: .66;
      }

      .el-menu-item:hover {
        color: #ec1500;
      }


      .el-menu-item.is-active {
        border-bottom: transparent;
        font-weight: bolder;
        font-size: 15px;
      }

      .el-menu-item.is-active::after {
        content: '';
        position: absolute;
        left: 50%;
        bottom: 0;
        margin-left: -0.8em;
        width: 1.4em;
        height: 2px;
        border-radius: 100px;
        background-color: #E76060;
      }
    }


    .el-menu.el-menu--horizontal {
      border-bottom: none;
    }
  }

  .content-list {
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 10px;

    .content-item {
      position: relative;
      width: calc(100% / 5);
      height: 254px;
      padding: 14px;
      margin: 0 24px 24px 0;
      background: #FFFFFF;
      border-radius: 8px;
      float: left;
      transition: all .2s;
      text-decoration: none;

      .content-bottom {
        font-size: 12px;
        color: #9199A1;
        line-height: 16px;
        margin-bottom: 18px;

        .price {
          font-weight: bold;
          color: red;
        }
      }

      .content-item-card {
        border: none;
        height: 100%;
        width: 100%;
        margin-bottom: 8px;
        border-radius: 8px 8px 0 0;

        .content-item-img {
          width: 100%;
          height: 152px;
        }

        .content-item-title {
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 2;
          color: #545C63;
          font-size: 10px;
          -webkit-box-orient: vertical;
        }

        .participation-num {
          display: block;
          color: #9199A1;
          font-size: 12px;
          margin-bottom: 8px;
        }
      }
    }

    .content-item:hover {
      content: '';
      box-shadow: 12px 12px 12px 1px rgb(95 101 105 / 15%);
    }
  }
}
</style>
